<template>
	<view class="content">
		<image mode="widthFix" :src="detail.picUrl" class="top-bg"></image>
		<view class="detail-block">
			<view class="name">{{detail.title?detail.title:''}}</view>
		</view>
		<view class="connection-block">
			<view class="phone-item" @click="callPhone">
				<view class="phone">联系电话：{{detail.telPhone?detail.telPhone:''}}</view>
				<view class="iconfont icon-youjiantou"></view>
			</view>
			<view class="address-item" @click="openMap">
				<view class="address">地理地址：{{detail.address}}</view>
				<view class="iconfont icon-daohang"></view>
			</view>
		</view>
		<view class="evaluation-block">
			<view class="title">简介</view>
			<view class="info">
				<mp-html :content="detail.content" />
			</view>
		</view>
	</view>
</template>

<script>
	import {
		postTravelById
	} from '@/api/tourism_service.js';
	export default {
		data() {
			return {
				detail: {

				}
			}
		},
		onLoad(e) {
			this.detail.id = e.id
			this.getTicketList()
		},
		methods: {
			openMap() {
				uni.openLocation({
					longitude: this.detail.longitude,
					latitude: this.detail.latitude,
					name: this.detail.title,
					address: this.detail.address,
				})
			},
			callPhone() {
				uni.makePhoneCall({
					phoneNumber: this.detail.telPhone,
					success() {
						console.log('拨打成功了');
					},
					fail() {
						console.log('拨打失败了');
					}
				})
			},
			getTicketList() {
				let id = this.detail.id
				postTravelById({
					id
				}).then((res) => {
					if (res.code == 1) {
						console.log(res)
						if (res.data != null) {
							this.detail = res.data;
							console.log(this.detail)
						}
					} else {
						console.log(res)
					}
				}).catch((res) => {
					console.log(res)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		display: flex;
		flex-direction: column;
		background: #F4F4F4;
		min-height: 100vh;
		padding-bottom: 140rpx;

		.top-bg {
			width: 100%;
			height: auto;
		}

		.detail-block {
			width: 100%;
			display: flex;
			flex-direction: column;
			background: #fff;
			margin-top: -60rpx;
			padding: 20rpx;

			.name {
				font-size: 34rpx;
				color: $color-primary-text;
				font-weight: bold;
				text-align: justify;
			}

		}

		.connection-block {
			background: #fff;
			margin: 20rpx 0 0 0;
			display: flex;
			flex-direction: column;
			font-size: 28rpx;
			padding: 0 20rpx;

			.phone-item {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px solid #efefef;

				.phone {
					display: flex;
					flex-direction: row;
					align-items: center;
					height: 80rpx;
				}

				.iconfont {
					font-size: 26rpx;
					color: #999;
				}
			}

			.address-item {
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: space-between;
				border-bottom: 1px solid #efefef;

				.address {
					display: flex;
					flex-direction: row;
					align-items: center;
					height: 90rpx;

				}
			}
		}


		.evaluation-block {
			display: flex;
			flex-direction: column;
			margin: 20rpx 0;
			background: #fff;
			padding: 30rpx 20rpx;
			padding-bottom: 0;

			.title {
				font-weight: bold;
			}

			.info {
				line-height: 1.8;
				font-size: 30rpx;
				margin: 0 10rpx;
			}
		}
	}
</style>
